package com.haibara.codesubmiteval.job;

import com.haibara.codesubmiteval.constant.FileConstant;
import com.haibara.codesubmiteval.utils.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@Slf4j
public class CleanTempFileTask {
    // 每日0点执行
    @Scheduled(cron = "0 0 0 * * ?")
    public void runCleanTempFileTask() {
        try {
            FileUtil.clearDirectory(FileConstant.tempFilePath);
            log.info("清空临时文件成功");
        } catch (IOException e) {
            log.info("清空临时文件失败, {}", e.getMessage());
        }
    }
}